<html>
<head>
    <META content="text/html;charset=utf-8" http-equiv="Content-Type">
    <style type="text/css">
        input {
            width: 100%;
        }
        .error {
            color: red;
        }
    </style>
</head>
<body>
<h1>Payment results</h1>
<div id="errorBlock"></div>

<fieldset>
    <legend>Payment results</legend>
    <table width="100%" id="paymentResults">
        <tr>
            <td>Parameter----</td>
            <td>Value</td>
        </tr>

        <?php
//        var_dump($_GET['orderId']);
        try {
            if(isset($_GET['orderId'])&&$_GET['orderId']!='')
            {
                header("Access-Control-Allow-Origin: *");
                $url = "https://epp.khanbank.com/payment/rest/getOrderStatus.do";

                $data = array('language'=> 'en',
                    'orderId' => $_GET['orderId'],
                    'userName' => 'HAPPYGOMALL',
                    'password' => 'CtH%^O[}2[9X"Q}U');

                $curl = curl_init();
                curl_setopt($curl, CURLOPT_FAILONERROR, 0);
                curl_setopt($curl, CURLOPT_HEADER, 0);
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
                curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
                curl_setopt($curl, CURLOPT_URL, $url);
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
                curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
                curl_setopt($curl, CURLOPT_ENCODING, "UTF-8");
                curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
                $response = curl_exec($curl);
                curl_close($curl);

                $responsearr = explode(',', $response);
                $replace_string = array('"', '}', '{');

                for($i=0; $i<count($responsearr); $i++)
                {
                    echo '<tr><td>';
                    $temp = str_replace($replace_string, '',$responsearr[$i]);
                    $temp2 = str_replace(':', '</td><td>', $temp);
                    echo $temp2."</td></tr>";
                }
            }

        } catch (Exception $e) {
            echo 'Connection did not succeed';
        }
        ?>
    </table>
</fieldset>

</body>
</html>